package com.useeinfo.oa.open.logger;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.action.BaseAction;
import com.useeinfo.framework.sugar.data.QueryParam;
import com.useeinfo.oa.common.annotations.LoggerAnnotations;
import com.useeinfo.oa.modules.logger.biz.ActiveLogBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/web/admin/activeLog")
public class ActiveLogAction extends BaseAction {

    @Autowired
    private ActiveLogBiz activeLogBiz;

    /**
     * 打开列表页面
     */
    @RequestMapping("/getActiveLogListPage")
    public ModelAndView getActiveLogListPage() {

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("pages/logger/activeLog/activeLogList");

        return modelAndView;
    }

    /**
     * 分页获取JSON数据
     */
    @RequestMapping("/getActiveLogListJSON")
    @ResponseBody
    @LoggerAnnotations(check = true, model = "LOG",remark = "查询操作")
    public JSONObject getActiveLogListJSON(@RequestParam(value = "page", required = false) String pageNowParam,
                                               @RequestParam(value = "rows", required = false) String pageSizeParam,
                                                @RequestParam(value = "keyNotes", required = false) String keyNotes,
                                               @RequestParam(value = "startDate", required = false) String startDate,
                                               @RequestParam(value = "endDate", required = false) String endDate,
                                               HttpServletRequest request) {
        QueryParam queryParam = new QueryParam(pageNowParam, pageSizeParam);
        queryParam.getSqlMap().put("keyNotes",keyNotes);
        queryParam.getSqlMap().put("startDate",startDate);
        queryParam.getSqlMap().put("endDate",endDate);
        JSONObject jsonList = activeLogBiz.findJSONList(queryParam);
        return jsonList;
    }

}
